package com.atguigu.demo.customer.mapper;


import com.atguigu.demo.customer.bean.Customer;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@DS("demo")
@Mapper
public interface CustomerMapper extends BaseMapper<Customer> {

    @Insert("insert into t_customer(id,name,age) values(#{customer.id}, #{customer.name},#{customer.age})")
    public  void  insertCustomer(@Param("customer")Customer customer);


    @Select("select id,name,age from t_customer where name like '%'||#{name}||'%'")
    List<Customer> selectCustomerListByName(@Param("name") String name);


    @Select("${sql}")
    List<Customer> selectCustomerList(@Param("sql") String sql);

    @Select("select id,name,age from t_customer where id=#{id}")
    Customer selectCustomerById(Long id);



    //补充 update 和 delete方法
}
